package edu.scsu.csci;

import edu.scsu.csci.context.ViewContext;
import edu.scsu.csci.util.ReflectionUtil;
import edu.scsu.csci.view.JSPView;

/**
 * <p> Interface to be implemented by all the provided view implementations. </p>
 * 
 * @author Maqbool Khan
 * @since jdk 1.5
 * @see	edu.scsu.csci.annotation.AView
 * @viz.diagram IView.tpx
 */
public interface IView {
	
	/**
	 * <p>	All the different view implementations are expected to 
	 * 		implement this method. </p>
	 * 
	 * <p>	This method is resposible for generating a presenatation
	 * 		after all the buisness processing has been performed. </p>
	 * 
	 * @param operationContext
	 * @param parameters
	 */
	void render(ViewContext viewContext);
	
	/**
	 * Creates an instnace of the view based on the View class provided.
	 *
	 * @author Maqbool Khan
	 * @since jdk 1.5
	 * @see
	 */
	final public static class ViewFactory {
		
		/**
		 * Creates an instance of view.
		 * 
		 * @param interceptors
		 * @return IView
		 */
		public static IView getInstance(Class<? extends IView> viewClazz)	{
			if(viewClazz == null)
				return new JSPView();
			
			return ReflectionUtil.instantiate(viewClazz);
		}
	}

}
